package com.dj.merchant.controller;

import com.dj.common.response.ApiResponse;
import com.dj.merchant.dto.OfflineStoreData;
import com.dj.merchant.endpoint.OfflineStoreBaseService;
import com.dj.merchant.model.OfflineStore;
import com.dj.merchant.service.OfflineInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author : Jimmy
 * @Date : 2020/12/17 15:41
 * @Desc : dj-version-tag
 **/
@RestController
@RequestMapping("/bas/merchant/v1.0")
public class OfflineStoreController implements OfflineStoreBaseService {


    @Autowired
    private OfflineInfoService offlineInfoService;


    @PostMapping("/offlineStore/create")
    public ApiResponse<Long> createOffline(@RequestBody OfflineStoreData offlineStoreData) {

        Long offline = offlineInfoService.createOffline(offlineStoreData);
        return ApiResponse.success(offline);
    }


    @GetMapping("/offlineStore/list")
    public ApiResponse<List<OfflineStore>> queryOfflineList(OfflineStoreData offlineStoreData){

        List<OfflineStore> offlineStores = offlineInfoService.selectOffline(offlineStoreData);
        return ApiResponse.success(offlineStores);
    }

    @PostMapping("/offlineStore/update")
    public ApiResponse<Long> updateOffline(@RequestBody  OfflineStoreData offlineStoreData){


        Long aLong = offlineInfoService.updateOffline(offlineStoreData);

        return ApiResponse.success(aLong);
    }


    @GetMapping("/offlineStore/get")
    public ApiResponse<OfflineStore> queryOffline(@RequestParam("storeId") String storeId){

        OfflineStore offlineStore = offlineInfoService.queryOffline(storeId);
        return ApiResponse.success(offlineStore);
    }

}
